#!/usr/bin/env python

class RingBuffer:
	""" ring buffer """
	def __init__(self, max_size):
		self.max=max_size
		self.data=[]
	class __Full:
		""" full buffer """
		def append(self,x):
			self.data[self.cur]=x
			self.cur=(self.cur+1) % self.max
		def get(self):
			return self.data[self.cur:]+self.data[:self.cur]
	def append(self,x):
		self.data.append(x)
		if len(self.data) == self.max:
			self.cur=0
			self.__class__ = self.__Full
	def get(self):
		return self.data
